<template>
  <div>
    <head-top
      routerName="rankingList"
      :blackRadian="false"
      title="排行榜"
    ></head-top>
    <div class="back">
      <div class="topThree">
        <template v-for="(item, index) in list">
          <template v-if="index <= 2">
            <div class="two" :key="index" v-if="index === 1">
              <van-image :src="item.headPic" />
              <div class="bg-two">No.2</div>
              <div class="name">
                {{ nickName(item.nickName, item.userName) }}
              </div>
              <div class="contribution">{{ item.contribute }}贡献值</div>
            </div>
            <div class="one" :key="index" v-else-if="index === 0">
              <van-image :src="item.headPic" />
              <div class="bg-one">No.1</div>
              <div class="name">
                {{ nickName(item.nickName, item.userName) }}
              </div>
              <div class="contribution">{{ item.contribute }}贡献值</div>
            </div>
            <div class="three" :key="index" v-else>
              <van-image :src="item.headPic" />
              <div class="bg-three">No.3</div>
              <div class="name">
                {{ nickName(item.nickName, item.userName) }}
              </div>
              <div class="contribution">{{ item.contribute }}贡献值</div>
            </div>
          </template>
        </template>
      </div>
    </div>

    <div class="content-wrap">
      <div class="list">
        <ul>
          <template v-for="(item, index) in list">
            <li :key="index" v-if="index >= 2">
              <div class="left">
                <div class="index">{{ index + 1 }}</div>
                <div class="name">
                  {{ nickName(item.nickName, item.userName) }}
                </div>
              </div>
              <div class="contribution">{{ item.contribute }}贡献值</div>
            </li>
          </template>
        </ul>
      </div>
    </div>
  </div>
</template>
<script>
import HeadTop from "@/components/head";
import { Image as VanImage } from "vant";
import { queryContribute } from "@/api/rankingList";
export default {
  components: {
    [VanImage.name]: VanImage,
    HeadTop,
  },
  data() {
    return {
      list: [],
    };
  },
  created() {
    queryContribute({}).then((res) => {
      this.list = res.data.resultData;
    });
  },
  computed: {
    nickName() {
      return function (nickName, userName) {
        return nickName ? nickName : userName;
      };
    },
  },
};
</script>
<style lang="less" scoped>
.back {
  background: #333333;
  .topThree {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 52px 0 0 0;
    width: 339px;
    margin: 0 auto;
    text-align: center;
    overflow: hidden;
    .two,
    .three {
      width: 107px;
      height: 144px;
      background: #ffffff;
      border-radius: 9px 9px 0px 0px;
    }
    .one {
      position: absolute;
      left: 0;
      right: 0;
      bottom: 0;
      margin: 0 auto;
      width: 133px;
      height: 175px;
      background: #ffffff;
      box-shadow: 0px 0px 30px 0px rgba(0, 0, 0, 0.06);
      border-radius: 9px 9px 0px 0px;
    }
    .two,
    .three,
    .one {
      .bg-two,
      .bg-one,
      .bg-three {
        position: relative;
        display: block;
        margin: -15px auto 0 auto;
        width: 77px;
        height: 30px;
        font-size: 16px;
        font-weight: 500;
        color: #ffffff;
        line-height: 22px;
        text-shadow: 0px 0px 2px rgba(254, 174, 72, 0.52);
        background-size: 77px 30px;
      }
      .bg-one {
        background-image: url("./no.1_icon_ranking@2x.png");
      }
      .bg-two {
        background-image: url("./no.2_icon_ranking@2x.png");
      }
      .bg-three {
        background-image: url("./no.3_icon_ranking@2x.png");
      }
      .van-image {
        margin: 26px auto 0 auto;
        display: block;
        width: 55px;
        height: 55px;
        overflow: hidden;
        border-radius: 55px;
      }
      .name {
        margin-top: 5px;
        height: 20px;
        font-size: 14px;
        font-weight: 400;
        color: #333333;
        line-height: 20px;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
      }
      .contribution {
        margin-top: 2px;
        height: 14px;
        font-size: 10px;
        font-weight: 400;
        color: #333333;
        line-height: 14px;
      }
    }
    .one {
      .van-image {
        margin-top: 19px;
      }
      .contribution {
        height: 17px;
        font-size: 12px;
        line-height: 17px;
      }
    }
  }
}

.list {
  ul {
    li {
      margin-top: 13px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      height: 56px;
      padding: 0 13px;
      box-shadow: 0px 0px 30px 0px rgba(0, 0, 0, 0.06);
      .left {
        color: #333333;
        display: flex;
        align-items: center;
        .name {
          margin-left: 13px;
          font-weight: 400;
          text-overflow: ellipsis;
          overflow: hidden;
          white-space: nowrap;
          max-width: 150px;
        }
      }
      .contribution {
        font-size: 14px;
        font-weight: 400;
        color: #333333;
      }
    }
  }
}
</style>